//package com.smile.handler;
//
//import com.alibaba.fastjson.JSONObject;
//import com.smile.mqtt.handler.AbstractAirportOrganizationGetHandler;
////import com.smile.service.entity.organization.AirportOrganizationInfo;
////import com.smile.service.entity.organization.AirportOrganizationResult;
////import com.smile.service.entity.response.DeviceConfigResponse;
//import org.eclipse.paho.client.mqttv3.MqttClient;
//import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
//import org.eclipse.paho.client.mqttv3.MqttException;
//import org.eclipse.paho.client.mqttv3.MqttMessage;
//import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
//import org.springframework.stereotype.Component;
//
//@Component
//public class DefaultAirportOrganizationGetHandler extends AbstractAirportOrganizationGetHandler {
//    @Override
//    public Boolean process(String data, String tid, String bid,String gateway) throws MqttException {
////        System.out.println("DefaultAirportOrganizationGetHandler data:" + data);
//        AirportOrganizationInfo airportOrganizationInfo = JSONObject.parseObject(data, AirportOrganizationInfo.class);
////        System.out.println(airportOrganizationInfo);
//
//        AirportOrganizationResult airportOrganizationResult = new AirportOrganizationResult();
//        airportOrganizationResult.setResultCode(0);
//        AirportOrganizationResult.OrganizationOutput organizationOutput = new AirportOrganizationResult.OrganizationOutput();
//        organizationOutput.setOrganizationName("飞行员一号");
//        airportOrganizationResult.setOutput(organizationOutput);
//        airportOrganizationResult.setResultCode(0);
//
//        DeviceConfigResponse<AirportOrganizationResult> deviceConfigResponse = new DeviceConfigResponse<>();
//        deviceConfigResponse.setBid(bid);
//        deviceConfigResponse.setTid(tid);
//        deviceConfigResponse.setData(airportOrganizationResult);
//
//        deviceConfigResponse.setTimestamp(System.currentTimeMillis());
//        deviceConfigResponse.setMethod("airport_organization_get");
//        deviceConfigResponse.setGateway("8UUXN2800A00HX");
//        System.out.println("DefaultAirportOrganizationGetHandler发送的结果为:" + JSONObject.toJSONString(deviceConfigResponse));
//
//
//        MqttMessage message = new MqttMessage();
//        message.setQos(0);
//        message.setRetained(true);
//        message.setPayload(JSONObject.toJSONString(deviceConfigResponse).getBytes());
//        MqttClient mqttClient = new MqttClient("tcp://120.211.119.131:1883", "feisuan-mqtt-producer-client", new MemoryPersistence());
//        MqttConnectOptions connOpts = new MqttConnectOptions();
//        connOpts.setUserName("feisuan");
//        connOpts.setPassword("feisuan123456".toCharArray());
//        mqttClient.connect(connOpts);
//
//        mqttClient.publish("thing/product/" + "8UUXN2800A00HX" + "/requests_reply", message);
//
//        return Boolean.TRUE;
//    }
//
//
//}
